#!/usr/bin/env python
import os
import sys
from hte.settings import BASE_DIR

if __name__ == '__main__':
    if os.getenv('HTEDATA_ENV', False):
        settings_path = 'hte.settings'
    elif os.path.exists(os.path.join(BASE_DIR, 'hte/local_settings.py')):
        settings_path = 'hte.local_settings'
    else:
        settings_path = 'hte.settings'

    os.environ['DJANGO_SETTINGS_MODULE'] = settings_path

    try:
        from django.core.management import execute_from_command_line
    except ImportError as exc:
        raise ImportError(
            "Couldn't import Django. Are you sure it's installed and "
            "available on your PYTHONPATH environment variable? Did you "
            "forget to activate a virtual environment?"
        )
    execute_from_command_line(sys.argv)
